package com.example.myspringframework.test;

import com.example.myspringframework.beans.BeansException;
import com.example.myspringframework.beans.factory.config.BeanPostProcessor;
import com.example.myspringframework.service.WorldService;

public class CustomBeanPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (bean instanceof WorldService) {
            System.out.println("初始化前执行-" + beanName);
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (bean instanceof WorldService) {
            System.out.println("初始化后执行-" + beanName);
        }
//        System.out.println("初始化后执行-"+beanName);
        return bean;
    }

}
